package com.wootion.dizhi.controller;

import com.wootion.dizhi.exception.BusinessException;
import com.wootion.dizhi.response.Result;
import com.wootion.dizhi.service.SystemDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@Api(tags = "系统数据")
@RestController
@RequestMapping("/system")
public class SystemDataController {

    @Resource
    private SystemDataService systemDataService;

    @ApiOperation("系统导入数据")
    @PostMapping("/dataImport")
    public Result dataImport(@RequestParam(value = "file")MultipartFile multipartFile) throws BusinessException, IOException {
        return systemDataService.dataImport(multipartFile);
    }

    @ApiOperation("系统导出数据")
    @GetMapping("/dataExport")
    public Result dataExport(){
        return systemDataService.dataExport();
    }
}
